<?php
if(!defined('ROOT_PATH')){//view目录的上一级目录
	define('ROOT_PATH',dirname(dirname(__FILE__)).'/' );
}
require(ROOT_PATH.'/config/config.php');
require_once(LIB_PATH."/myframe.php");//框架

$request = new myrequest();
$router  = new myrouter($request);

//controller
$objName = $router->getControllerName();
if($objName=='adminCon'){
	$controllerFile = LIB_PATH."controller/admin.con.php";
}else {
	$controllerFile = $router->getControllerFile();
}

if(!file_exists($controllerFile)){
    myresponse::showConfirm("访问路径错误，请联系系统管理员！");
}

require_once($controllerFile);


//act
$obj = new $objName($request);
$actName = $router->getActName();

//check if is admin
if(IS_ADMIN_SYS){
	if($objName=='tokenCon'){//token可以直接访问无需登录
		
	}else if(!mylogin::isAdmin()){//不是admin ,jump to admin login page
		if(!($objName=='adminCon' && ($actName=='logoutAction' || $actName=='loginAction' || $actName=='checkAction' || $actName=='createAction' || $actName=='initAction' || $actName=='imageAction'))){
			myresponse::redirect('admin,login',5,"请登录以后操作！");
		}
	}
}


$obj->$actName($request);



